//-----------------------------------------------------------------------
// <copyright file="ArticleService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class ArticleService
    {
        #region Article

        public static void CreateArticle(Article article)
        {            
            try
            {
                ArticleDAO articleDAO = new ArticleDAO();
                articleDAO.CreateArticle(article);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateArticleException, ex);
            }
        }        

        public static void UpdateArticle(Article article)
        {            
            try
            {
                ArticleDAO articleDAO = new ArticleDAO();
                articleDAO.UpdateArticle(article);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateArticleException, ex);
            }
        }        

        public static void DeleteArticle(long articleId)
        {            
            try
            {
                ArticleDAO articleDAO = new ArticleDAO();
                articleDAO.DeleteArticle(articleId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteArticleException, ex);
            }
        }
        
        public static Article GetArticle(long articleId)
        {            
            try
            {
                ArticleDAO articleDAO = new ArticleDAO();
                return articleDAO.GetArticle(articleId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetArticleException, ex);
            }
        }                

        public static ArticleCollection GetArticleList(ArticleColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                ArticleDAO articleDAO = new ArticleDAO();
                return articleDAO.GetArticleList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetArticleListException, ex);
            }
        }        

        public static ArticleCollection GetArticleList(ArticleColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                ArticleDAO articleDAO = new ArticleDAO();
                return articleDAO.GetArticleList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetArticleListException, ex);
            }
        }        

	    public static ArticleCollection GetArticleListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                ArticleDAO articleDAO = new ArticleDAO();
                return articleDAO.GetArticleListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetArticleListException, ex);
            }
        }        

        public static ArticleCollection GetArticleListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                ArticleDAO articleDAO = new ArticleDAO();
                return articleDAO.GetArticleListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetArticleListException, ex);
            }
        }        

        #endregion
    }
}